package view;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Point;
import java.util.Set;

import model.Model;
import model.entity.BasicEntity;
import model.entity.Entity;
import model.entity.stats.StatSet;
import model.entity.stats.StatType;
import model.map.World;
import model.skill.Observation;
import model.skill.SkillType;
	
public class ObservationOverlay extends Overlay {
	private Entity e;
	
	public ObservationOverlay(Dimension size, Entity e) {
		super(size);
		this.e = e;
		Observation o = (Observation)e.getOccupation().getNonActivateableSkill(SkillType.OBSERVATION);
		o.register(this);
	}
	
	public void update(Model m) {
		
	}
	protected void drawOverlay(Graphics g) {
		//System.out.println("Painting for Observation Overlay");
		
		g.setColor(Color.WHITE);
		Font font = new Font(Font.SANS_SERIF, Font.BOLD, 12);
		g.setFont(font);
		//g.drawString("HP: ????>>>>>>>>>>>>>>>", 400, 300);
		//Observation o = new Observation();//(Observation)e.getOccupation().getNonActivateableSkill(SkillType.OBSERVATION);
		Observation o = (Observation)e.getOccupation().getNonActivateableSkill(SkillType.OBSERVATION);
		StatSet s = null;
		Point p = null;
		int strOffset = 10;
		Set<BasicEntity> entityList = EntityOnScreen.getVisibleEntityKeyList();
		for (BasicEntity be : EntityOnScreen.getVisibleEntityKeyList()) {
			//draw what Avatar sees currently
			try {
				s = o.getStats(e, be);
				p = EntityOnScreen.getPoint(be);
				//Things to draw
				//Level
				//HP
				//Items
				//Benjamins
				//TODO Add HP status bar if more time is available
				//g.drawString(s.getStat(StatType.LEVEL).toString(), p.x, p.y);
				g.drawString("HP: " + s.getStat(StatType.HP).toString(), p.x, p.y*strOffset*1);
				//g.drawString("Items: " + e.getInventoryItems().size(), p.x, p.y*strOffset*2);
				//g.drawString("Benjamins: " + s.getStat(StatType.MONEY).toString(), p.x, p.y*strOffset*3);
			}
			catch (Exception e) {
				p = EntityOnScreen.getPoint(be);
				//g.drawString("LEVEL: ??", p.x, p.y);
				g.drawString("HP: ????", p.x, p.y);
				//g.drawString("HP: ????>>>>>>>>>>>>>>>", 400, 300);
				//g.drawString("LEVEL: ?????", p.x, p.y);
			}
		}
		g.setColor(Color.black);
	}
	public void onResize() {
		
	}
	/**
	 * @param e the e to set
	 */
	public void setE(Entity e) {
		this.e = e;
	}
	/**
	 * @return the e
	 */
	public Entity getE() {
		return e;
	}
}
